package com.xx.app.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class JsonUtil {

    private static final ObjectMapper objectMapper = new ObjectMapper();

    /**
     * 将对象转换为 JSON 字符串
     *
     * @param obj 要转换的对象
     * @return JSON 字符串
     */
    public static String convertObjectToJson(Object obj) {
        try {
            return objectMapper.writeValueAsString(obj);
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return null;
    }

    public static void main(String[] args) {
        /*ReturnInvestmentConfigVo
                vo = new ReturnInvestmentConfigVo();
        vo.setFeeRatio(new BigDecimal("0"));
        vo.setExchangeRatio(new BigDecimal("5"));
        vo.setRewardsRatio(new BigDecimal("1"));
        vo.setMinAmount(new BigDecimal("1"));
        vo.setMultiplier(new BigDecimal("2.5"));
        vo.setStatus(1);
        vo.setRemark("增值配置");
        vo.setLastModifiedTime(new Date());
        String json = convertObjectToJson(vo);
        System.out.println(json);*/
    }
}
